package yxk.task;

import kd.bos.context.RequestContext;
import kd.bos.exception.KDException;
import kd.bos.schedule.executor.AbstractTask;
import yxk.task.utils.SaveSignCardsService;
import yxk.utils.DateUtil;

import java.util.Calendar;
import java.util.Date;
import java.util.Map;

/**
 * 自动补卡上个月的2、3次打卡数据
 */
public class SignCardsServiceMonthTask extends AbstractTask {
    @Override
    public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
        SaveSignCardsService signCards=new SaveSignCardsService();
        Calendar instance = Calendar.getInstance();
        Date month = DateUtil.MonthAdd(instance.getTime(), Calendar.MONTH, -1);

        Date ofMonth = DateUtil.getFirstTimeOfMonth(month);
        //获取当月最晚时刻
        Date dateEnd = DateUtil.getEndTimeOfMonth(month);

        signCards.signApplyScheduled(ofMonth,dateEnd);
    }
}
